package us.mooresr.geartrack.server.handler;

import us.mooresr.geartrack.server.DAO;
import us.mooresr.geartrack.shared.action.PutItemTypeAction;
import us.mooresr.geartrack.shared.action.PutItemTypeResult;
import us.mooresr.geartrack.shared.model.ItemType;

import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import com.gwtplatform.dispatch.shared.ActionException;

public class PutItemTypeActionHandler implements ActionHandler<PutItemTypeAction, PutItemTypeResult> {

	@Override
	public PutItemTypeResult execute(PutItemTypeAction action,
			ExecutionContext arg1) throws ActionException {
		DAO dao = new DAO();
		
		ItemType newItemType = action.getItemTypeIn();
		
		dao.ofy().put(newItemType);
		
		PutItemTypeResult result = new PutItemTypeResult(newItemType);
		
		return result;
	}

	@Override
	public Class<PutItemTypeAction> getActionType() {
		return PutItemTypeAction.class;
	}

	@Override
	public void undo(PutItemTypeAction arg0, PutItemTypeResult arg1,
			ExecutionContext arg2) throws ActionException {
		// TODO Auto-generated method stub
		
	}

}
